package com.redis.controller;


import com.redis.utils.SeckillUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/8/17 16:57
 */
@RestController
@RequestMapping("/redis")
public class SecKillController {
    @Autowired
    private SeckillUtil seckillUtil;

    @GetMapping("/kill")
    public String skill() {
        String uid = UUID.randomUUID().toString().replaceAll("-", "");
        String prodid = "goods";
        boolean b = seckillUtil.soSecKill(uid, prodid);
        if (b) {
            return "秒杀成功";
        } else {
            return "秒杀失败";
        }
    }
}
